package org.example.fanruan;

import java.util.Scanner;

public class ArrayMaxCount {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 1;
        int many = in.nextInt();
        int temp;
        for (int i = 1; i < n; i++) {
            temp = in.nextInt();
            if (count == 0) {
                many = temp;
                count++;
                continue;
            }
            count += (many == temp ? 1 : -1);
        }
        System.out.println(many);
    }
}
